//
//  ViewController.m
//  模态视图
//
//  Created by student on 16/2/25.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"
#import "ViewControllerB.h"
#import "ViewControllerC.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;

@property (weak, nonatomic) IBOutlet UILabel *resultLable1;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // (UIStoryboardSegue *)segue 连线对象
    // 两个重要属性:
    //    segue.identifier 连线的名字 (用于判断是哪根线)
    //    segue.destinationViewController  连线的目标控制器(得到目标控制器，以便传递数据给它)
    if([segue.identifier isEqualToString:@"gotoB"])
    {
        ViewControllerB *vcB = segue.destinationViewController;
        vcB.userName = self.nameTextField.text;
        vcB.passWord = self.passwordTextField.text;
    }
    else if([segue.identifier isEqualToString:@"gotoC"])
    {
        //将要跳转到C
        ViewControllerC *vcC = segue.destinationViewController;
        //告诉C页面，我是你的代理人，注册好了回调我
        vcC.delegate = self;
        
    }
}
#pragma mark -ViewControllerC Delegate Method 实现ViewControllerC的协议里的方法
-(void)transUserName:(NSString *)u andPassword:(NSString *)p andEmail:(NSString *)e
{
    //得到C传来的数据
    self.resultLable1.text = [NSString stringWithFormat:@"注册成功！\n %@ %@ %@",u,p,e];
}
@end
